package com.example.champtionthree.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.champtionthree.R;
import com.example.champtionthree.bean.ExamInfo;

import java.util.ArrayList;

public class SecondeAdapter extends RecyclerView.Adapter<SecondeAdapter.ViewHolder> {
    private  ArrayList<ExamInfo.SmallItemInfo> value;
    private Context mContext;

    public SecondeAdapter(ArrayList<ExamInfo.SmallItemInfo> value, Context mContext) {
        this.value = value;
        this.mContext = mContext;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.seconde,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ExamInfo.SmallItemInfo smallItemInfo = value.get(position);
        Glide.with(mContext).load(smallItemInfo.image_url).into(holder.imageView);
        holder.textView1.setText(smallItemInfo.name);
        holder.textView2.setText(smallItemInfo.description);
        holder.textView3.setText("共"+smallItemInfo.video_count+"集");

    }

    @Override
    public int getItemCount() {
        return value!=null ? value.size():0;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        TextView textView1;
        TextView textView2;
        TextView textView3;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            imageView=itemView.findViewById(R.id.iv_ima);
            textView1=itemView.findViewById(R.id.tv_title);
            textView2=itemView.findViewById(R.id.tv_text);
            textView3=itemView.findViewById(R.id.tv_name);

        }
    }
}
